package com.Questions.tanxin;

import java.util.*;
/**
 * 会议室
 */
public class leetcode252 {
    public boolean canAttendMeetings1(int[][] intervals) {
        for(int i=0;i<intervals.length;i++){
            for(int j=i+1;j<intervals.length;j++){
                if(intervals[j][0]>intervals[i][0]&&intervals[j][0]<intervals[i][1]){
                    return false;
                }
            }
        }
        return true;
    }
    public boolean canAttendMeetings(int[][] intervals) {
        Arrays.sort(intervals, (a, b) -> Integer.compare(a[0], b[0]));
        for (int i = 0; i < intervals.length - 1; i++) {
            if (intervals[i][1] > intervals[i + 1][0]) {
                return false;
            }
        }
        return true;
    }

}
